package com.zhouyu.mybatis.spring;

import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.classreading.MetadataReader;

import java.io.IOException;
import java.util.Set;

/**
 * @author mimao funfind@yeah.net
 * @date ${{
 */
public class WangBeanDefinitonScanner extends ClassPathBeanDefinitionScanner {
	public WangBeanDefinitonScanner(BeanDefinitionRegistry registry) {
		super(registry);
	}

	// 这个方法，需要判断是否生成bean
	@Override
	protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
//		return super.isCandidateComponent(metadataReader);
		return beanDefinition.getMetadata().isInterface();
	}

	@Override
	public int scan(String... basePackages) {
		return super.scan(basePackages);
	}

	@Override
	protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
		Set<BeanDefinitionHolder> beanDefinitionHolders = super.doScan(basePackages);
		return beanDefinitionHolders;
	}
}
